var id,scenicId
$(function () {
    id = ly.getUrlParam("id") || '';
    scenicId = ly.getUrlParam("scenicId") || '';
    if (id) {
		$(".title span,title").html("编辑");
		request({
			url: site.gateUrl + '/back/epidemicManage/selectEpidemicManageById',
			data: { 'id': id},
			ajaxform: true,
			type: 'post',
			callback: function (r) {
				if (r.code == "rest.success") {
					var d = r.result;                    
                    $("#skipUrl").val(d.skipUrl)
                    $("#imgUrl input").val(d.imgUrl)
                    if(d.imgUrl!=null){
                        var img="<img src='"+site.gateUrl + d.imgUrl +"'>"
                        $('#imgUrl .imgbox').html(img)
                    }
                    $("#isUsing").getSelect({
                        type:"radio",
                        asName:"isUsing",
                        list:[
                            {value:"1",display:"启用"},
                            {value:"0",display:"禁用"}
                        ],
                        default:d.isUsing			
                    });
							
				} else {
					ly.toast(r.msg);
				}
			}
		});
	} else {
		$("#isUsing").getSelect({
			type:"radio",
			asName:"isUsing",
			list:[
				{value:"1",display:"启用"},
				{value:"0",display:"禁用"}
			],
			default:'1'			
		});
	}
})


//提交回到列表页
function  reviewBtn() {
	event.preventDefault();
	var imgUrl=$("#imgUrl input").val()
    var skipUrl=$("#skipUrl").val()
    var isUsing=$("#isUsing input[name=isUsing]:checked").val();
	
	if(skipUrl==''){
        ly.toast('请输入跳转路径');   
        return false
	}
	if(imgUrl==''){
		ly.toast('请上传图片');
		return false
	}
	if(isUsing==''){
		ly.toast('请选择是否启用');
		return false
	}
    var urls =''+site.gateUrl+'/back/epidemicManage/insertOrUpdateEpidemicManage'
    if(id==''){
        id=null
    }
	request({
		url:urls ,
		data:{
            id:id,
            skipUrl:skipUrl,
            imgUrl: imgUrl,
            isUsing: isUsing
        },
		ajaxform:false,
		type: 'post',
		callback: function(r) {
			if(r.code=="rest.success"){
				ly.alert("保存成功", function() {
                    window.history.go(-1)
                });
			}else{

			}
		}
	});
}